package com.zdw.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zdw.demo.entity.PcPubCallbackUrl;
import com.zdw.demo.mapper.PcPubCallbackUrlMapper;
import com.zdw.demo.service.PcPubCallbackUrlService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * Service : 回调地址 服务类
 * 用于处理实际的业务逻辑。
 */
@Service
@Slf4j
public class PcPubCallbackUrlServiceImpl extends ServiceImpl<PcPubCallbackUrlMapper, PcPubCallbackUrl> implements PcPubCallbackUrlService {

    @Autowired
    private PcPubCallbackUrlMapper urlMapper;

    /**
     * 根据appFlag应用标识,批量查询回调地址
     *
     * @param appFlag
     * @return
     */
    public PcPubCallbackUrl selectByQuery(String appFlag) {
        LambdaQueryWrapper<PcPubCallbackUrl> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PcPubCallbackUrl::getAppFlag, appFlag);
        return urlMapper.selectOne(queryWrapper);
    }

    /**
     * (批量)根据appFlag应用标识,批量查询回调地址
     *
     * @param appFlags
     * @return
     */
    public List<PcPubCallbackUrl> selectListByQuery(List<String> appFlags) {
        LambdaQueryWrapper<PcPubCallbackUrl> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(PcPubCallbackUrl::getAppFlag, appFlags);
        return urlMapper.selectList(queryWrapper);
    }

    /**
     * 根据outTradeNo内部订单号,批量查询回调地址
     *
     * @param outTradeNo
     * @return
     */
    public String selectByOutTradeNo(String outTradeNo) {
        return urlMapper.selectByOutTradeNo(outTradeNo);
    }

}
